package com.tywj.buscustomerapp.view.item;

import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.tywj.buscustomerapp.R;
import com.tywj.buscustomerapp.model.bean.DaysBean;
import com.tywj.buscustomerapp.model.bean.MonthTicketBean;
import com.tywj.buscustomerapp.utils.myadapter.item.AdapterItem;

public class MyTravelMonthItem implements AdapterItem<DaysBean> {
    private TextView tiemView;
    private TextView stateView;
    private TextView travelView;
    private TextView startView;
    private TextView endView;
    private TextView bus_time;
    private TextView bus;
    private Context context;

    @Override
    public int getLayoutResId() {
        return R.layout.item_mytravel;
    }

    @Override
    public void bindViews(@NonNull View root) {
        tiemView = root.findViewById(R.id.time);
        stateView = root.findViewById(R.id.state);
        travelView = root.findViewById(R.id.travel_number);
        startView = root.findViewById(R.id.start);
        endView = root.findViewById(R.id.end);
        bus_time = root.findViewById(R.id.bus_time);
        bus = root.findViewById(R.id.bus);
        context = root.getContext();

    }

    @Override
    public void setViews() {

    }

    @Override
    public void handleData(DaysBean bean, int position) {
        bus.setVisibility(View.VISIBLE);
        bus_time.setText("");
        tiemView.setText(bean.getKssj()+"-"+bean.getDqsj());
        startView.setText("起始日期"+bean.getKssj());
        endView.setText("截止日期"+bean.getDqsj());
        stateView.setText(bean.getState());
        travelView.setText(bean.getCityName()+"周期票");

        if (bean.getState().equals("待乘车")){
            stateView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.tag_ori));
            stateView.setTextColor(context.getResources().getColor(R.color.white));
            //            stateView.setBackgroundColor(context.getResources().getColor(R.color.toasterro));
        }else if (bean.getState().equals("已乘车")){
            stateView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.tag_green));
            stateView.setTextColor(context.getResources().getColor(R.color.text_tab));
//            stateView.setBackgroundColor(context.getResources().getColor(R.color.appColor));
//            stateView.setTextColor(context.getResources().getColor(R.color.white));
        }else if (bean.getState().equals("已完成")){
            stateView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.tag_green));
            stateView.setTextColor(context.getResources().getColor(R.color.text_tab));
//            stateView.setBackgroundResource(R.mipmap.icon_tag);
//            stateView.setTextColor(context.getResources().getColor(R.color.textblack));
        }else{
            stateView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.tag_yellow));
            stateView.setTextColor(context.getResources().getColor(R.color.text));
        }
    }
}
